package com.atguigu.schedule.util;

import com.alibaba.fastjson.JSONObject;
import com.atguigu.schedule.common.Result;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

public class WebUtil {
    public static void writeJson(HttpServletResponse res, Result result){
        String jsonString = JSONObject.toJSONString(result);
        res.setContentType("application/json;charset=UTF-8");
        try {
            res.getWriter().write(jsonString);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
